/*
 * @Author: lixiang
 * @Date: 2021-11-03 16:26:31
 * @Description: 
 */
import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    isCollapse: false,
    relevanceId: 0,
    type: 0, // 文章类型 1-产品详情
    screenHeight: document.documentElement.clientHeight, //屏幕高度
    menuList: localStorage.getItem('menuList') ? JSON.parse(localStorage.getItem('menuList')) : [],// 当前所打开的menu列表
    activeTabs: localStorage.getItem('activeTabs') ? JSON.parse(localStorage.getItem('activeTabs')) : {},// 当前所打开的tab标签
  },
  mutations: {
    /**
     * 保存菜单
     * @param {*} state 
     * @param {*} collapse 
     */
    saveMenuList(state, menuList) {
      state.menuList = menuList;
      localStorage.setItem('menuList', JSON.stringify(menuList))
    },
    /**
    *  //保存标签table
    * @param {*} state 
    * @param {*} collapse 
    */
    saveActiveTab(state, activeTab) {

      state.activeTabs = activeTab;
      localStorage.setItem('activeTabs', JSON.stringify(activeTab))
      
    },

    // changeMenu
    changeState(state, collapse) {
      state.isCollapse = collapse;
    },
    changeRelevanceId(state, relevanceId) {
      state.relevanceId = relevanceId;
    },
    changeType(state, type) {
      state.type = type;
    }
  },
  actions: {
  }
});
